<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>资源管理</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <%@include file="../include/commonFile.jsp" %>
</head><body>
<!--头部-->
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <form class="layui-form" action="${ctx}/resource/resource/resourceList.do" id="myForm" method="post">
                <input type="hidden" name="pageNo" id="pageNo"/>
                <div class="f-search-bar">
                    <div class="search-container">
                        <ul class="search-form-content">
                            <li class="form-item-inline"><label class="search-form-lable">标题</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="title" autocomplete="off" class="layui-input"
                                           value="${resource.title}" placeholder="请输入查询标题">
                                </div>
                            </li>
                            <li class="form-item-inline"><label class="search-form-lable">资源类型</label>
                                <div class="layui-input-inline">
                                    <select name="type">
                                        <option value="">全部</option>
                                        <c:forEach var="type" items="${resourceTypes}">
                                            <option value="${type.value}" ${resource.type == type.value ? 'selected="selected"' : ''}>${type.label}</option>
                                        </c:forEach>
                                    </select>
                                </div>
                            </li>
                            <li class="form-item-inline">
                                <div class="sub-btns">
                                    <a class="layui-btn layui-btn-danger"
                                       href="javascript:submitFunction('#myForm')">查询</a> <a
                                        class="layui-btn layui-btn-normal"
                                        href="javascript:resetFunction('#myForm')">重置</a>
                                </div>
                            </li>
                        </ul>
                        <ul class="search-form-content">
                            <li class="form-item"><label class="search-form-lable">添加时间</label>
                                <div class="check-btn-inner" id="timeType">
                                    <a id="all" href="javascript:void(0);"
                                       onclick="setTimeType($(this),0,'#myForm')" ${empty input.timeType || input.timeType == 0 ? 'class="active"' : ''}>全部</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),1,'#myForm')" ${input.timeType == 1 ? 'class="active"' : ''}>今天</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),2,'#myForm')" ${input.timeType == 2 ? 'class="active"' : ''}>本周内</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),3,'#myForm')" ${input.timeType == 3 ? 'class="active"' : ''}>本月内</a>
                                    <input type="hidden" name="timeType" value="${input.timeType}"/>
                                </div>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createStart"
                                               value="${input.createStart}" placeholder="开始日"
                                        >
                                    </div>
                                    -
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createEnd"
                                               value="${input.createEnd}" placeholder="截止日"
                                        >
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </form>
            <div class="c-time-list-content">
                <ul>
                    <c:if test="${page.totalCount == 0}">
                        <div class="f16 tc mt15">还没有数据，请点击右上角的“添加资源”</div>
                    </c:if>
                    <c:forEach var="resource" items="${resources}">
                        <li>
                            <div class="detail-content">
                                <a href="javascript:void(0)" class="act-logo common-img"
                                   >
                                  <img src="<c:if test="${ resource.pic!= null}">${resource.pic}?imageMogr2/auto-orient/crop/200x150</c:if>" alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                </a>
                                <div class="detail">
                                    <div class="act-title">
                                        <a href="javascript:void(0);"
                                           class="title f18 ell db">${resource.title}</a>
                                    </div>
                                    <div class="">
                                        <p class="act-price">
                                            发布时间：
                                            <fmt:formatDate value="${resource.createDate}" pattern="yyyy-MM-dd HH:mm"/>
                                        </p>
                                        <p class="act-price">
                                            类型：
                                            <c:forEach var="type" items="${resourceTypes}">
                                                <c:if test="${type.value == resource.type}">${type.label}</c:if>
                                            </c:forEach>
                                        </p>
                                        <p class="start-time ell" style="width: 65%" title="${ resource.remarks }">
                                            描述：${ resource.remarks }</p>
                                    </div>
                                    <div class="opts-btns tb-opts" style="width:475px">
                                        <div class="comm-opts">
                                            <a href="${ctx}/resource/resource/resourceForm.do?id=${resource.id}"> <i
                                                    class="iconfont icon-edit btn-icon"></i>
                                                编辑
                                            </a> <a
                                                href="javascript:txz.deleteObject('确定要删除资源吗？','${ctx}/resource/resource/delete.do?id=${resource.id}','')">
                                            <i
                                                    class="iconfont icon-delete btn-icon"></i> 刪除
                                        </a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </li>
                    </c:forEach>
                </ul>
            </div>
            <div>
                <c:if test="${page.totalCount > 0}">
                    <div class="l" style="width: 200px; padding-left: 30px; padding-top: 10px;">
						<span class="f14 red">共<b id="totalCount">${page.totalCount}</b>条记录
						</span>
                    </div>
                </c:if>
                <div id="page_content" class="page-container"></div>
            </div>
        </div><!--底部-->
        <%@include file="../include/footer.jsp" %>
</section>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript">

    $(function () {
//加载分页
        loadPageNew({elem: 'page_content', totalCount: '${page.totalCount}', limit: '${page.limit}', page: '${page.page}'});
        layui.use(['laydate'], function () {
            var laydate = layui.laydate;
            // 查询发布日期
            var start = {
                elem: 'input[name=createStart]'
            };

            var end = {
                elem: 'input[name=createEnd]'
            };
            laydate.render(start);
            laydate.render(end);
        });
    })
    <%--showActive('${input.createStart}', '${input.createEnd}', '#timeType');--%>
</script>
<script type="text/javascript">
    txz.initHeader({
        nav:[{
            name: '资源管理',
            curr: true
        }],
        btns:[{
            name: '添加资源',
            href: '${ctx}/resource/resource/resourceForm.do',
            icon: 'add'
        }]
    });
</script>
</body>
</html>